package com.xing.statistics.controller;


import com.xing.commonutils.R;
import com.xing.statistics.service.DailyService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * <p>
 * 网站统计日数据 前端控制器
 * </p>
 *
 * @author xingfuao
 * @since 2022-04-13
 */
@RestController
@RequestMapping("/statistics/daily")
@CrossOrigin  //解决跨域问题
public class DailyController {

    @Autowired
    private DailyService dailyService;


    //统计某一天得注册人数
    @ApiOperation("统计某一天得注册人数")
    @PostMapping("/createStatisticByDay/{day}")
    public R createStatisticByDay(@PathVariable String day) {
        dailyService.createStatisticByDay(day);
        return R.ok();
    }

    //图表显示，返回两部分数据，日期json数组,数据json数组
    @GetMapping("/showData/{type}/{begin}/{end}")
    public R showData(@PathVariable String type, @PathVariable String begin, @PathVariable String end) {
        Map<String, Object> map = dailyService.getShowData(type, begin, end);
        return R.ok().data(map);
    }

}

